package com.kuang.controller;

import com.github.pagehelper.PageInfo;
import com.kuang.entity.Achievement;
import com.kuang.entity.Params;
import com.kuang.entity.SysUser;
import com.kuang.service.*;
import com.kuang.util.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    private UserService userService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private MajorService majorService;
    @Autowired
    private AchievementService  achievementService;


    @GetMapping("/hello")
    public ResultModel<String> hello(){
        return ResultModel.success("你好,教师角色");
    }

    /***
     * 注册账号申请管理
     * **/
    @PutMapping("/accountManagement")
    public ResultModel accountManagement(@RequestBody SysUser sysUser){
        userService.accountManagement(sysUser);
        return ResultModel.success();
    }
    /**
     * 教师系统：学生账号分页查询
     */
    @GetMapping("/search")
    public ResultModel findBySearch(Params params) {
        PageInfo info = userService.TeFindBySearchStudent(params);
        return ResultModel.success(info);
    }


    /**
     * 认定审核通过
     * **/
    @PutMapping("/affirmAchievementPass")
    public ResultModel SuccessfullyApprovedAchievement(@RequestBody Achievement achievement){
        achievementService.SuccessfullyApprovedAchievement(achievement);
        return ResultModel.success();
    }
    /**
     * 认定审核不通过
     * **/
    @PutMapping("/affirmAchievementFail")
    public ResultModel failApprovedAchievement( @RequestBody Achievement achievement){
        achievementService.failApprovedAchievement(achievement);
        return ResultModel.success();
    }
    /**
     * 转换审核通过
     * **/
    @PutMapping("/PassTransformationOfLearningOutcomes")
    public ResultModel PassTransformationOfLearningOutcomes(@RequestBody Achievement achievement){
        achievementService.PassTransformationOfLearningOutcomes(achievement);
        return ResultModel.success();
    }
    /**
     * 转换审核不通过
     * **/
    @PutMapping("/FailTransformationOfLearningOutcomes")
    public ResultModel FailTransformationOfLearningOutcomes( @RequestBody Achievement achievement){
        achievementService.FailTransformationOfLearningOutcomes(achievement);
        return ResultModel.success();
    }

    /**
     * 学习成果认定分页查询
     */
    @GetMapping("/searchAffirm")
    public ResultModel TeFindBySearchAffirm(Params params) {
        PageInfo info = achievementService.TeFindBySearchAffirm(params);
        return ResultModel.success(info);
    }
    /**
     * 学习成果转换分页查询
     */
    @GetMapping("/searchTransitio")
    public ResultModel TeFindBySearchTransition(Params params) {
        PageInfo info = achievementService.TeFindBySearchTransition(params);
        return ResultModel.success(info);
    }
    /**
     *查询学院下拉框信息
     * **/
    @GetMapping("/findAll")
    public ResultModel findAll() {
        List list = departmentService.findAll();
        return ResultModel.success(list);
    }

    /**
     *查询专业下拉框信息
     * **/
    @GetMapping("/findAoo")
    public ResultModel findAoo() {
        List list = majorService.findAoo();
        return ResultModel.success(list);
    }
}
